use core::result;

pub type Result<T> = result::Result<T, PaError>;

#[derive(Debug)]
#[allow(clippy::upper_case_acronyms)]
pub enum PaError {
    ENOMEM,
    EORDER,
    EMAPCOUNT,
    EREFCOUNT,
    ECHECK,
    ENOTAIL,
    ENOCOMP,
}

impl PaError {
    pub fn to_errno_msg(&self) -> &str {
        match self {
            Self::ENOMEM => "Out of memory",
            Self::EORDER => "Order invalid",
            Self::EMAPCOUNT => "Nonzero mapcount",
            Self::EREFCOUNT => "Nonzero refcount",
            Self::ECHECK => "Check at free flag(s) set",
            Self::ENOTAIL => "PageTail not set",
            Self::ENOCOMP => "Comp head not consistent",
        }
    }
}
